package com.example.myapplication.util;

import org.json.JSONException;
import org.json.JSONObject;

/***
 * Json转换工具
 *
 * @author minicle
 */
public class JsonUtil {

    public static String getCarName(String jsonStr) {
        String string = null;
        try {
            JSONObject obj = new JSONObject(jsonStr);
            string = obj.getJSONObject("result").getString("name");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return string;
    }

    public static String getCarPrice(String jsonStr) {
        String string = null;
        try {
            JSONObject obj = new JSONObject(jsonStr);
            string = obj.getJSONObject("result").getString("fctprice");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return string;
    }

    public static String getLevelName(String jsonStr) {
        String string = null;
        try {
            JSONObject obj = new JSONObject(jsonStr);
            string = obj.getJSONObject("result").getString("levelname");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return string;
    }
}